package com.neusoft.a312cxy.android18cxy.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;

import com.neusoft.a312cxy.android18cxy.Listener.PostListener;
import com.neusoft.a312cxy.android18cxy.R;
import com.neusoft.a312cxy.android18cxy.model.ShaiTuModel;

/**
 * Created by Young on 2017/10/26.
 */

public class AddpicActivity extends AppCompatActivity {
    private ImageButton addpicBtn;
    private EditText neirong;
    private Button fabu;
    private String thumb,userid,club_id,title;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_addpic);
        initView();
        saveDate();

       // getClubCourse();




    }
    private void saveDate(){
        Intent intent = getIntent();
        Bundle  bundle =  intent.getExtras();;
        userid = bundle.getString("userid");
    }


    private void initView() {
        addpicBtn=(ImageButton)findViewById(R.id.addpicBtn);
        neirong=(EditText)findViewById(R.id.neirong);
        fabu=(Button)findViewById(R.id.fabu);
        fabu.setOnClickListener(new View.OnClickListener(){
            @Override            public void onClick(View view) {

                title = neirong.getText().toString();
                ShaiTuModel shaiTuModel = new ShaiTuModel();
                shaiTuModel.addpic(thumb,"19",title,club_id,addpic );
                //  edt.getText().toString().trim()
            }
        });
    }
    PostListener<String> addpic=new PostListener<String>() {
        @Override
        public void onResponse(String post) {
            if (post.equals("0")){
                Toast.makeText(AddpicActivity.this, "发布失败", Toast.LENGTH_SHORT).show();

            }else {
                Toast.makeText(AddpicActivity.this, "发布成功", Toast.LENGTH_SHORT).show();
                finish();
            }
        }

        @Override
        public void onFail(String msg) {

        }
    };


}
